<template>
	<view class="record_window_container">
		<u-popup mode="bottom" closeable round="24rpx" :show="visible" @close="handleColse">
			<view class="pop_content">
				<view class="mt_16 fc fc_666 fz_18">
					砍价记录
				</view>
				<view class="coupon_list box plr_16 fx fx_col">
					<view class="fx_1 flow_y">
						<view class="ptb_12 plr_16 fx jcb flow_h" v-for="item,index in list" :key="index">
							<view class="fx">
								<CusImage width="80rpx" height="80rpx" radius="40rpx" :src="item.customerHeadUrl" />
								<view class="asstr fx fx_col jcb ml_8">
									<view>{{item.customerName||''}}</view>
									<view class="fc_999">
										{{item.bargainirgTime||''}}
									</view>
								</view>
							</view>
							<view class="fz_12 fc_primary">
								已砍<text class="fc_primary">{{item.bargainirgPrice||0}}</text>元
							</view>
						</view>
						<view class="ptb_16" v-if="!list.length&&loading">
							<u-loadmore />
						</view>
						<view class="mt_32" v-if="!list.length&&!loading">
							<Empty />
						</view>
					</view>
				</view>
			</view>
		</u-popup>
	</view>
</template>

<script>
	import Empty from '@/components/Empty.vue'
	import CusImage from '@/components/Image'
	import api from '@/service/config/api.js'
	export default {
		components: {
			Empty,
			CusImage
		},
		props: {
			visible: {
				default: false,
				type: Boolean
			},
			data: {
				default: () => ({}),
				type: Object
			},
		},
		data() {
			return {
				list: [],
				loading: true,
			}
		},
		watch: {
			visible(newVal) {
				if (newVal) {
					this.loading = true
					api.get('/goods/api/product/bargainirgRecordList', {
						id: this.data.id,
					}, {
						noHideLoading: true
					}).then(res => {
						this.list = res.data
					}).finally(() => {
						this.loading = false
					})
				}
			}
		},
		methods: {
			// 关闭弹窗
			handleColse() {
				this.$emit('update:visible', false)
			},
		},
	}
</script>

<style lang="scss">
	.record_window_container {
		.coupon_list {
			height: 528rpx;
		}

		.list_item+.list_item {
			margin-top: 24rpx;
		}
	}
</style>